package cn.gok.common.dao.backstage;

import cn.gok.common.entity.backstage.SysMenu;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author: DxlinY
 * @apiNote: 后台管理系统菜单持久层
 * @date: 2020/9/26
 * @time: 14:59
 */
@Repository
@Mapper
public interface SysMenuMapper extends BaseMapper <SysMenu> {

    /**
     * 查询用户菜单
     *
     * @param id 用户编号
     * @return list
     */
    @Select("SELECT " +
            "sm.MENU_ID,sm.PARENT_ID,sm.MENU_NAME,sm.URL,sm.icon " +
            "FROM " +
            "sys_menu sm," +
            "sys_role_menu srm, " +
            "sys_user_role sur " +
            "WHERE " +
            "sm.MENU_ID = srm.MENU_ID " +
            "AND srm.ROLE_ID = sur.ROLE_ID " +
            "AND sur.USER_ID = #{id} " +
            "AND sm.type != '2';")
    List <SysMenu> getMenusById(long id);
}
